Skip to content

Conversation

zhijianli88
Copy link
Collaborator

@zhijianli88 zhijianli88 commented Nov 10, 2020

rebase trace-ot to apiserver_opentelemetry

trace-ot: https://github.com/Hellcatlk/kubernetes/tree/trace-ot
apiserver-opentelemetry: https://github.com/dashpole/kubernetes/tree/apiserver_opentelemetry

start kube-apiserver with additional args:
--feature-gates=APIServerTracing=true
--opentelemetry-config-file=/etc/kubernetes/pki/APITracing-config.yaml

$ cat /etc/kubernetes/pki/APITracing-config.yaml
 apiVersion: apiserver.k8s.io/v1alpha1                                           
 kind: OpenTelemetryClientConfiguration    

in the webhook, you can get the traceid and spancontext like below:

[root@k8s-master mutating-trace-admission-controller]# kubectl logs trace-context-injector-webhook-deployment-64b4b8f5cc-fnbtl 
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[6454] Content-Type:[application/json] Traceparent:[00-a900e667a58c3a38c6ce4fad5bc6cfa3-ff74e238cdaa3a57-00] User-Agent:[kube-apiserver-admission]]
UPDATE
Deployment
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[4781] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-b6b1a5838f2b1d9a3229b35fa977b12f-dae8ff7033dca8db-00] User-Agent:[kube-apiserver-admission]]
UPDATE
ReplicaSet
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[2806] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-b6b1a5838f2b1d9a3229b35fa977b12f-1efa853c20836245-00] User-Agent:[kube-apiserver-admission]]
CREATE
Pod
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[3153] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-a900e667a58c3a38c6ce4fad5bc6cfa3-a3c51fd003a223ef-00] User-Agent:[kube-apiserver-admission]]
CREATE
ReplicaSet
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[2806] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-a900e667a58c3a38c6ce4fad5bc6cfa3-c79f261ecf9d4757-00] User-Agent:[kube-apiserver-admission]]
CREATE
Pod
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[4781] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-b6b1a5838f2b1d9a3229b35fa977b12f-257b4ca2c78f74a8-00] User-Agent:[kube-apiserver-admission]]
UPDATE
ReplicaSet
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[4781] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-b6b1a5838f2b1d9a3229b35fa977b12f-ff49918d4d89c810-00] User-Agent:[kube-apiserver-admission]]
UPDATE
ReplicaSet
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[4781] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-b6b1a5838f2b1d9a3229b35fa977b12f-1d6836517fcb8860-00] User-Agent:[kube-apiserver-admission]]
UPDATE
ReplicaSet
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[4781] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-a900e667a58c3a38c6ce4fad5bc6cfa3-339d90c85b4bbf14-00] User-Agent:[kube-apiserver-admission]]
UPDATE
ReplicaSet
-------------------------------------
-------------------------------------
map[Accept:[application/json, */*] Accept-Encoding:[gzip] Content-Length:[2806] Content-Type:[application/json] Otcorrelations:[Initial-Trace-Id=60889a79-62fe-47ff-a051-c98a46cb72fe] Traceparent:[00-a900e667a58c3a38c6ce4fad5bc6cfa3-47aa1de685bb3781-00] User-Agent:[kube-apiserver-admission]]
CREATE
Pod
-------------------------------------

Signed-off-by: Li Zhijian [email protected]

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@zhijianli88 zhijianli88 force-pushed the apiserver_opentelemetry_traceid branch from fc55a3b to d289379 Compare November 11, 2020 09:49
all components want to propagate SpanContext via http header are required to
init trace. Otherwise, RoundTrip will start a noopSpan which will
override the origin span, then it causes the origin span(SpanContext) lost

Signed-off-by: Li Zhijian <[email protected]>
Signed-off-by: Li Zhijian <[email protected]>
@zhijianli88 zhijianli88 force-pushed the apiserver_opentelemetry_traceid branch 3 times, most recently from 5672692 to bd18dde Compare December 16, 2020 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant